class MaintainStylesController < ApplicationController
  before_action :set_menu

  def index
  	@submenu = :maintain_style
    @title = '维修项目管理'
  	@maintain_styles = MaintainStyle.all
  end

  def new
    @maintain_style = MaintainStyle.new
  end

  def create
    @maintain_style = MaintainStyle.new post_params
    if @maintain_style.save
       redirect_to maintain_styles_path
    else
      render :action => 'new'
    end
  end

  def edit
    @maintain_style = MaintainStyle.find params[:id]
  end

  def update
    @maintain_style = MaintainStyle.find params[:id]
    if @maintain_style.update_attributes post_params
      redirect_to maintain_styles_path
    else
      render :action => 'edit'
    end
  end


  def destroy
    @maintain_style = MaintainStyle.find params[:id]
    @maintain_style.destroy
    redirect_to maintain_styles_path
  end

  def show
    @title = "维修项目管理/明细"
    @buttons.push :action => maintain_styles_path, :label => "返回"
    @maintain_style = MaintainStyle.find params[:id]
  end


   def post_params
    params.require(:maintain_style).permit(*%w(name))
  end

  private
  def set_menu
    @mainmenu = :base_data
  end
end
